package com.kgc.scd.producer;

import com.kgc.scd.bean.SearchHistory;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.Destination;
import java.util.List;

/**
 * Created On : 2022/6/11.
 * <p>
 * Author     : hi
 * <p>
 * Description: SearchHistoryProducer
 */
@Slf4j
@RestController
public class SearchHistoryProducer {
    @Autowired(required = false)
    private JmsMessagingTemplate jmsMessagingTemplate;

    /**
     * @description : 使用P2P模式， 发送消息队列
     */

    public void sendP2P(String SearchHistoryName ,SearchHistory searchHistory){
        //创建一个目标消息队列对象（消息的缓存容器，缓存发送的消息体）
        Destination destination = new ActiveMQQueue(SearchHistoryName);
        //发送消息到目标队列
        jmsMessagingTemplate.convertAndSend(destination,searchHistory);

    }

    public void delP2P(String SearchHistoryName ,String historyValue){
        //创建一个目标消息队列对象（消息的缓存容器，缓存发送的消息体）
        Destination destination = new ActiveMQQueue(SearchHistoryName);
        //发送消息到目标队列
        jmsMessagingTemplate.convertAndSend(destination,historyValue);

    }
}
